import 'package:photo_view/photo_view.dart';
import 'package:syria_sports/core/app_export.dart';

import '../../widgets/app_bar/appbar_subtitle.dart';
import '../../widgets/app_bar/custom_app_bar.dart';
import '../../widgets/app_bar/outline_icon_button.dart';
import 'photo_view_screen_cubit.dart';
import 'package:flutter/material.dart';

class PhotoViewScreenScreen extends StatelessWidget {
  final ImageProvider? image ;
  const PhotoViewScreenScreen({super.key, required this.image});

  @override
  Widget build(BuildContext context) {
    double height = MediaQuery.of(context).size.height;
    double width = MediaQuery.of(context).size.width;

    return Scaffold(
      appBar:_buildAppBar(context:context),
      body: BlocProvider<PhotoViewScreenCubit>(
        create: (context) => PhotoViewScreenCubit(),
        child: BlocConsumer<PhotoViewScreenCubit, PhotoViewScreenState>(
          listener: (context, state) {
            // TODO: implement listener
          },
          builder: (context, state) {
            var cubit = PhotoViewScreenCubit.get(context);
          
            return Container(
              height: height,
              width: width,
              clipBehavior: Clip.antiAlias,
              decoration: BoxDecoration(),
              child: PhotoView(
                backgroundDecoration: BoxDecoration(
                  color: theme.scaffoldBackgroundColor,
                ),
                imageProvider: image??Image.asset(ImageConstant.icLogo).image,
              ),
            );
          },
        ),
      ),
    );
  }
  /// Section Widget
  PreferredSizeWidget _buildAppBar({required BuildContext context}) {
    return CustomAppBar(
      leading: OutlineIconButton(
        imagePath: ImageConstant.imgRightIcon,
        onTapped: (){
          Navigator.pop(context);
        },
      ),
      title: AppbarSubtitle(
        text: "صورة", margin: EdgeInsets.only(left: 12.h),
      ),
    );
  }
}